using System;
namespace HB.Expand
{
    public static class NumberRange
    {    
        public static bool BetweenIn(this sbyte data, sbyte min, sbyte max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this sbyte data, sbyte min, sbyte max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this double data, double min, double max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this double data, double min, double max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this byte data, byte min, byte max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this byte data, byte min, byte max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this short data, short min, short max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this short data, short min, short max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this ushort data, ushort min, ushort max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this ushort data, ushort min, ushort max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this ulong data, ulong min, ulong max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this ulong data, ulong min, ulong max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this uint data, uint min, uint max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this uint data, uint min, uint max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this float data, float min, float max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this float data, float min, float max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this int data, int min, int max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this int data, int min, int max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool BetweenIn(this long data, long min, long max)
        {
            if (data >= min && data <= max)
            {
                return true;
            }
            else { return false; }
        }
        public static bool OutsideOf(this long data, long min, long max)
        {
            if (data < min || data > max)
            {
                return true;
            }
            else { return false; }
        }
        /// <summary>
        /// 验证字符串长度
        /// </summary>
        /// <param name="str"></param>
        /// <param name="minLen"></param>
        /// <param name="maxLen"></param>
        /// <returns></returns>
        public static bool BetweenIn(this string str, int minLen, int maxLen)
        {
            bool result = false;
            if (str != null)
            {
                int len = str.Trim().Length;
                if (len >= minLen && len <= maxLen)
                {
                    result = true;
                }
            }
            return result;
        }
        /// <summary>
        /// 验证字符串长度
        /// </summary>
        /// <param name="str"></param>
        /// <param name="minLen"></param>
        /// <param name="maxLen"></param>
        /// <param name="conditionOr">允许的其他条件</param>
        /// <returns></returns>
        public static bool BetweenIn(this string str, int minLen, int maxLen, Func<string, bool> conditionOr)
        {
            bool result = BetweenIn(str, minLen, maxLen);
            if (!result)
            {
                result = conditionOr?.Invoke(str) ?? false;
            }
            return result;
        }
        /// <summary>
        /// 判定是否为空或null
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this string str)
        {
            return string.IsNullOrEmpty(str);
        }

        /// <summary>
        /// 判定是否不为(空或null)
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsNoNullOrEmpty(this string str)
        {
            return !string.IsNullOrEmpty(str);
        }
    }
}
